package com.android.dialnowsms;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.pm.PackageManager.NameNotFoundException;

public class About{
  public void showAboutDialog(SMSComposer smsComposer) {
  Builder AboutDlg = new AlertDialog.Builder(smsComposer).setMessage(
      smsComposer.getString(R.string.about).replace("\\n", "\n").replace(
      "${VERSION}", getVersion(smsComposer))).setTitle(
          smsComposer.getString(R.string.menu_about)).setIcon(R.drawable.sms)
              .setCancelable(true);
  AboutDlg.show();
  }

  public static String getVersion(Context context) {
    final String unknown = "Unknown";
    if (context == null) {
      return unknown;
    }
    try {
      return context.getPackageManager().getPackageInfo(
          context.getPackageName(), 0).versionName;
    } catch (NameNotFoundException ex) {
    }
    return unknown;
  }
}
